package org.smart4j.chapter1.plugin.security;

import org.apache.shiro.realm.jdbc.JdbcRealm;
import org.smart4j.chapter1.helper.DatabaseHelper;
import org.smart4j.chapter1.plugin.security.password.Md5CredentialMatcher;

/**
 * @ClassName:
 * @Description: 基于Smart的JDBC Realm(需要提供相关smart.plugin.security.jdbc.* 配置项)
 * @Author: LynnZou
 * @Date: 2017/5/31
 */
public class SmartJdbcRealm extends JdbcRealm {


    public SmartJdbcRealm() {
        super.setDataSource(DatabaseHelper.getDataSource());
        super.setAuthenticationQuery(SecurityConfig.getJdbcAuthQuery());
        super.setUserRolesQuery(SecurityConfig.getJdbcRolesQuery());
        super.setPermissionsQuery(SecurityConfig.getJdbcPermissionsQuery());
        super.setPermissionsLookupEnabled(true);
        super.setCredentialsMatcher(new Md5CredentialMatcher());

    }
}
